﻿using Coldairarrow.Entity.DingReving;
using Coldairarrow.Entity.DTO;
using Coldairarrow.Entity.PB;
using Coldairarrow.Entity.TD;
using Coldairarrow.Util;
using Coldairarrow.Util.ClassLibrary;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace Coldairarrow.Business.TD
{
    public partial interface ITD_ReceivingBusiness
    {
        Task<PageResult<TD_Receiving>> GetDataListAsync(PageInput<ConditionDTO> input);
        Task<TD_Receiving> GetTheDataAsync(string id);
        Task AddDataAsync(TD_Receiving data);
        Task UpdateDataAsync(TD_Receiving data);

        Task AddOutDataAsync(TD_Receiving data);
        Task UpdateOutDataAsync(TD_Receiving data);

        Task DeleteDataAsync(List<string> ids);
        Task<PageResult<TD_Receivinginfo>> GetDataListinfo(PageInput<ReceivingConditionDTO> input);
        /// <summary>
        /// 获取收货单的已入库的明细信息
        /// </summary>
        /// <param name="receivingId">收货单Id</param>
        /// <returns></returns>
        Task<List<PB_UpLoadListDataDTO>> GetLocalMaterial_SListAsync(string receivingId);
        Task<AjaxResult> SaveToExamine(QuerServeTOExamineDTO QueryTable);
        Task<AjaxResult> SaveStartJob(string idIn);

        /// <summary>
        /// 扫描物料
        /// </summary>
        /// <param name="packqrcode">物料二维码</param>
        /// <param name="recqrcode">收货单二维码</param>
        /// <returns></returns>
        Task<PB_MaterialRecDetailDTO> GetMaterialRecDetailDataAsync(string packqrcode, string recqrcode);

        /// <summary>
        /// 根据收货单上架入库
        /// </summary>
        /// <param name="data"></param>
        /// <param name="_redisOptions"></param>
        /// <returns></returns>
        Task SaveShelfStorageAsync(WarehousingDTO data, RedisOptions _redisOptions);
        /// <summary>
        /// 待维打包上架入库
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        Task SaveRecoveryWarehousingDto(RecoveryWarehousingDto data);
        ///待维入库依据收货单物料获取剩余入库数量 
        Task<List<PB_UpLoadListDataDTO>> GetLocalMaterialOldAsync(string receivingId);
        Task<ReceivePackDetail> GetReceivePackDetail(string packQrcode, string RecId);
        /// <summary>
        /// 待维入库扫码收货单获取明细信息
        /// </summary>
        /// <param name="QrCode"></param>
        /// <returns></returns>
        Task<List<TD_RecDetailInfo>> GetTD_ReceivingInfo(string QrCode, string MaterName);
        /// <summary>
        /// 上架入库复核
        /// </summary>
        /// <param name="receivingId">收货单Id</param>
        /// <returns></returns>
        Task SubmitLocalMaterialAsync(string receivingId);

        /// <summary>
        /// 上架入库提交
        /// </summary>
        /// <param name="receivingId">收货单Id</param>
        /// <returns></returns>
        Task SubmitReceingAsync(string receivingId);

        /// <summary>
        /// 收货单复核退回改为开始作业状态
        /// </summary>
        /// <param name="receivingId">收货单Id</param>
        /// <returns></returns>
        Task UpReceReturnAsync(string receivingId);


        /// <summary>
        /// 打印收货单
        /// </summary>
        /// <param name="ParentId"></param>
        /// <returns></returns>
        Task<List<TD_Receivinglistinfo>> GetDataListInfos(string ParentId);

        /// <summary>
        /// 删除已入库的包信息
        /// </summary>
        /// <param name="receivingId">收货单id</param>
        /// <param name="data">库存包信息</param>
        /// <returns></returns>
        Task DeleteStockDataAsync(string receivingId, PB_UpLoadListDataDTO data);

        /// <summary>
        /// 收货单打码明细
        /// </summary>
        /// <param name="recid">收货单id</param>
        /// <returns></returns>
        Task<List<TD_RecDetailPrintDTO>> GetRecDetailPrintListAsync(string recid);


        /// <summary>
        /// 收货单物料二维码打印
        /// </summary>
        /// <param name="data"></param>
        /// <param name="_mongodbOptions"></param>
        /// <param name="_redisOptions"></param>
        /// <returns></returns>
        Task RecDetailPrintListDataAsync(RecDetailPrintDTO data, MongoDBOptions _mongodbOptions, RedisOptions _redisOptions);

        /// <summary>
        /// 收货单物料二维码打印(推送包码和成品码)
        /// </summary>
        /// <param name="data"></param>
        /// <param name="_mongodbOptions"></param>
        /// <param name="_redisOptions"></param>
        /// <returns></returns>
        Task RecDetailPrintListAsync(RecDetailPrintDTO data, MongoDBOptions _mongodbOptions, RedisOptions _redisOptions);

        /// <summary>
        /// 成品物料明细
        /// </summary>
        /// 增加分页逻辑  2022-02-18  赵锦涛
        /// <returns></returns>
        Task<PageResult<JobBookingMaterialDTO>> GetRecDetailJobBookingQrCodeAsync(PageInput<PB_JobBookingQrCodeConditionDTO> input);

        /// <summary>
        /// 成品物料补打
        /// </summary>
        /// <param name="data"></param>
        /// <param name="_mongodbOptions"></param>
        /// <returns></returns>
        Task PrintRecDetailJobBookingQrCodeAsync(PB_DesignDetailPrintDataDTO data, MongoDBOptions _mongodbOptions);

        /// <summary>
        /// 成品物料对应的包明细
        /// </summary>
        /// <param name="recid">收货单id</param>
        /// <param name="MaterialId">物料Id</param>
        /// <returns></returns>
        Task<List<PB_PackListRecDTO>> GetRecPackListDataAsync(string recid, string MaterialId);

        /// <summary>
        /// 成品物料对应的包补打
        /// </summary>
        /// <param name="data"></param>
        /// <param name="_mongodbOptions"></param>
        /// <returns></returns>
        Task PrintRecPackListDataAsync(PB_DesignDetailPrintDataDTO data, MongoDBOptions _mongodbOptions);


        /// <summary>
        /// 收货单作废
        /// </summary>
        /// <param name="Id">收货单id</param>
        /// <returns></returns>
        Task CancelReceivingDataAsync(string Id);

        #region  半成品入库

        /// <summary>
        /// 获取半成品信息
        /// 根据流转卡统计完的数量入库
        /// </summary>
        /// <param name="CirBillQrCode">流转卡二维码</param>
        /// <returns></returns>
        Task<CirBillMaterialDTO> GetCirBillMaterialDataAsync(string CirBillQrCode);

        /// <summary>
        /// 半成品通知入库
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        Task SaveCirBillStorDataAsync(CirBillStorData data);

        /// <summary>
        /// PDA根据收货单上架入库扫描流转单获取物料信息
        /// </summary>
        /// <param name="CirBillQrCode">流转卡二维码</param>
        /// <returns></returns>
        Task<CirBillMaterialRecDTO> GetCirBillMaterialRecDataAsync(string CirBillQrCode);

        #endregion

        #region 回货入库打码

        /// <summary>
        /// 回货入库打码
        /// </summary>
        /// <param name="data"></param>
        /// <param name="_mongodbOptions"></param>
        /// <param name="_redisOptions"></param>
        /// <returns></returns>
        Task PrintRecoveryListAsync(RecoveryMaterialDTO data, MongoDBOptions _mongodbOptions, RedisOptions _redisOptions);

        #endregion

    }

    public class RecDetailPrintDTO
    {
        /// <summary>
        /// 收货单号
        /// </summary>
        public string recid { get; set; }

        /// <summary>
        /// 收货单物料明细
        /// </summary>
        public List<string> liststr { get; set; }

        /// <summary>
        /// 包打印机
        /// </summary>
        public string PrinterId { get; set; }

        /// <summary>
        /// 物料打印机
        /// </summary>
        public string MaterialPrinterId { get; set; }

        /// <summary>
        /// 是否推送队列并生成包码
        /// </summary>
        public Boolean? IsPushQueue { get; set; }

        public Boolean? IsMax { get; set; }

    }

    public class ReceivingConditionDTO
    {
        public string Keyword { get; set; }

        /// <summary>
        /// 状态
        /// </summary>
        public int? Status { get; set; }

        /// <summary>
        /// 收货类型
        /// </summary>
        public string Type { get; set; }

        public string RecTime { get; set; }
        /// <summary>
        /// 收货日期
        /// </summary>
        public DateTime? StartDate { get; set; }

        /// <summary>
        /// 结束日期
        /// </summary>
        public DateTime? EndDate { get; set; }
        /// <summary>
        /// 收货人
        /// </summary>
        public string ConfirmUserIdName { get; set; }

        /// <summary>
        /// 物料信息
        /// </summary>
        public string MaterName { get; set; }
    }

    /// <summary>
    /// 收货单，单个物料补码列表
    /// </summary>
    public class JobBookingMaterialDTO
    {
        /// <summary>
        /// Id
        /// </summary>
        public string Id { get; set; }

        /// <summary>
        /// 物料Id
        /// </summary>
        public string MaterialId { get; set; }

        /// <summary>
        /// 物料名称
        /// </summary>
        public string MaterialName { get; set; }

        /// <summary>
        /// 物料编码
        /// </summary>
        public string MaterialCode { get; set; }

        /// <summary>
        /// 成品二维码
        /// </summary>
        public string QrCode { get; set; }

    }

    /// <summary>
    /// 收货单物料补码
    /// 增加收货单物料补码分页模式   --2022-02-18 赵锦涛
    /// </summary>
    public class PB_JobBookingQrCodeConditionDTO
    {
        /// <summary>
        /// 搜索条件
        /// </summary>
        public string Keyword { get; set; }

        /// <summary>
        /// 收货单ID
        /// </summary>
        public string recid { get; set; }

        /// <summary>
        /// 物料ID
        /// </summary>
        public string MaterialId { get; set; }
    }

    /// <summary>
    /// 收货单实际上架信息
    /// </summary>
    public class UpLoadListDTO
    {
        /// <summary>
        /// 收货单Id
        /// </summary>
        public string ParentId { get; set; }

        /// <summary>
        /// 仓库Id
        /// </summary>
        public string StorId { get; set; }

        /// <summary>
        /// 货位Id
        /// </summary>
        public string LocalId { get; set; }

        /// <summary>
        /// 库区Id
        /// </summary>
        public string AreaId { get; set; }

        /// <summary>
        /// 货架Id
        /// </summary>
        public string RackId { get; set; }

        /// <summary>
        /// 单价
        /// </summary>
        public Double? Price { get; set; }

        /// <summary>
        /// 数量
        /// </summary>
        public Double? Nums { get; set; }

        /// <summary>
        /// 包Id
        /// </summary>
        public string PackId { get; set; }

        /// <summary>
        /// 物料Id
        /// </summary>
        public string MaterialId { get; set; }

        /// <summary>
        /// 是否新旧：0-旧；1-新
        /// </summary>
        public int? OldOrNew { get; set; }

        /// <summary>
        /// 成品Id
        /// </summary>
        public string JobId { get; set; }

    }

    #region  半成品入库

    /// <summary>
    /// 获取半成品信息（获取流转卡物料信息）
    /// </summary>
    public class CirBillMaterialDTO
    {
        /// <summary>
        /// 流转卡Id
        /// </summary>
        public string CirBillId { get; set; }

        /// <summary>
        /// 物料Id
        /// </summary>
        public string MaterialId { get; set; }

        /// <summary>
        /// 物料名称
        /// </summary>
        public string MaterialName { get; set; }

        /// <summary>
        /// 物料编码
        /// </summary>
        public string MaterialCode { get; set; }

        /// <summary>
        /// 物料规格
        /// </summary>
        public string MaterialSpec { get; set; }

        /// <summary>
        /// 流转卡类型
        /// </summary>
        public int? Type { get; set; }

        /// <summary>
        /// 流转卡统计数量
        /// </summary>
        public Double? Nums { get; set; }

    }

    /// <summary>
    /// 半成品入库保存
    /// </summary>
    public class CirBillStorData
    {
        /// <summary>
        /// 仓库Id
        /// </summary>
        public string StorId { get; set; }

        /// <summary>
        /// 半成品入库通知明细
        /// </summary>
        public List<CirBillMaterialDTO> ListMaterialData { get; set; }

    }

    /// <summary>
    /// PDA上架入库扫描流转单获取物料信息
    /// </summary>
    public class CirBillMaterialRecDTO
    {
        /// <summary>
        /// 流转卡Id
        /// </summary>
        public string CirBillId { get; set; }

        /// <summary>
        /// 物料Id
        /// </summary>
        public string MaterialId { get; set; }

        /// <summary>
        /// 物料名称
        /// </summary>
        public string MaterialName { get; set; }

        /// <summary>
        /// 物料编码
        /// </summary>
        public string MaterialCode { get; set; }

        /// <summary>
        /// 物料规格
        /// </summary>
        public string MaterialSpec { get; set; }

        /// <summary>
        /// 任务单明细Id
        /// </summary>
        public string TaskDetailId { get; set; }

        /// <summary>
        /// 单价
        /// </summary>
        public Double? Price { get; set; }

        /// <summary>
        /// 仓储单位Id
        /// </summary>
        public string storageId { get; set; }

        /// <summary>
        /// 流转卡统计数量
        /// </summary>
        public Double? Nums { get; set; }

        /// <summary>
        /// 收货单Id
        /// </summary>
        public string RecId { get; set; }

    }

    #endregion

    #region 回货入库打码Model

    public class RecoveryMaterialDTO
    {

        /// <summary>
        /// 收货单Id
        /// </summary>
        public string RecId { get; set; }

        /// <summary>
        /// 要打印的明细信息
        /// </summary>
        public List<TD_RecDetailPrintDTO> RecDetailList { get; set; }

        /// <summary>
        /// 包码打印机Id
        /// </summary>
        public string PrinterId { get; set; }

        /// <summary>
        /// 物料打印机Id
        /// </summary>
        public string MaterialPrinterId { get; set; }

    }

    #endregion

    #region 收货单作废

    public class PB_UpLoadListDTO : PB_UpLoadList
    {
        /// <summary>
        /// 是否新旧：0-旧；1-新
        /// </summary>
        public int? OldOrNew { get; set; }

        /// <summary>
        /// 库存明细Id
        /// </summary>
        public string localdetailId { get; set; }
    }

    #endregion

    #region 外协收货打码获取外协单的项目和楼号

    public class OutBillOrderDTO
    {
        /// <summary>
        /// 收货单Id
        /// </summary>
        public string RecId { get; set; }

        /// <summary>
        /// 项目Id
        /// </summary>
        public string ProjectId { get; set; }

        /// <summary>
        /// 项目名称
        /// </summary>
        public string ProjectName { get; set; }

        /// <summary>
        /// 楼号Id
        /// </summary>
        public string BuildingNumberID { get; set; }

        /// <summary>
        /// 楼号
        /// </summary>
        public string BuildingNumberName { get; set; }

    }

    #endregion

}